package Serveur;


import java.net.InetAddress;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashSet;

import Client.IClient;

// SKULL
public class Client extends UnicastRemoteObject implements IClient {
	private static final long serialVersionUID = -1644939890198944622L;
	private String email;
	private Serveur serveur;
	public IServeur iServeur;
	
	protected Client() throws RemoteException {
		super();
	}
	
	protected Client(Serveur serveur) throws RemoteException {
		this.serveur = serveur;
		// TODO Auto-generated constructor stub
	}
	
	public boolean authentificate(String mail, String password) throws RemoteException {
		if(DB.authentificate(mail, password)) {
			Serveur.clients.add(this);
			this.email = mail;
			serveur.bindServeur(this);
			return true;
		}
		else return false;
	}
	
	public HashSet<HashSet<String>> getTweets() throws RemoteException {
		return DB.getTweets(this.email);
	}
	
	public void sendTweet(String tweet) throws RemoteException {
		serveur.onReceive(tweet, this);
	}
	
	public String getEmail()  {
		return this.email;
	}
}
